<!DOCTYPE html>
<html>
<head>
<meta charset="UTF-8">
<title>Insert title here</title>
<link rel="stylesheet" href="../../../js/layui/css/layui.css" />
<script src="../../../js/vue/vue.js"></script>
<script src="../../../js/vue/axios.min.js"></script>
<script src="../../../js/layui/layui.js"></script>
<style type="text/css">
.zth-botton-but {
	margin-left: 200px;
	margin-top: 100px;
}
</style>
</head>
<body>
	<div id="app" class="layui-form">
		<div class="layui-form-item">
			<label class="layui-form-label">复选框</label>
			<div class="layui-input-block">

				<input type="checkbox" v-for="ss in tag_names" :value="ss.tag_id"
					v-model="name" :title="ss.tag_name" />
			</div>

		</div>

	</div>

	<script type="text/javascript">
			var $;
			var das="saandsa";
			layui.use(['form','jquery'], function() {
				var form = layui.form
				$=layui.jquery; 
			});
			
			//获取到标签id
			var href=location.href;
			var index=href.indexOf("?");
			var sub=href.substr(index+4,href.length);
			var subs=[];
			if(sub!=null && sub!=''){
				subs=sub.split(",")
			}
			
			var vm=new Vue({
				el: '#app',
				data(){
					return{
					tag_id: 0, //标签id
					tag_name: "", //标签名称
					tag_names: [] ,//储存标签
					name:subs//储存标签id，进行数据回显
}
				},
				mounted:function(){
					this.tagShow();
				},
				methods: {
					//获取全部标签
					tagShow: function() {
						axios.get('/ssb/tag/tagAll').then(res => {
							this.tag_names=res.data.list;
						},err=>{
							console.log(err);
						})
					},
					submit:function(){
						//将页面全部复选框选中的值拼接到一个数组中
						var arr_box = [];
						$('input[type=checkbox]:checked').each(function() {
						  arr_box.push($(this).val());
						});
						/* axios.get('/ssb/blog/getTag?blog_tags='+arr_box).then(res=>{
							console.log(res);
						},err=>{
							console.log(err);
						}); */
						
						var ss=$.ajax({
							url:'/ssb/blog/getTag',
							data:{
								blog_tags:arr_box
							},
							dataType:"JSON",
							cache : false,
							async : false,
							success:function(res){
								/* layui.use(['form', 'jquery',], function() {
									layer.alert("添加成功！", function() {
										var index = parent.layer.getFrameIndex(window.name); //获取窗口索引
										parent.layer.close(index);
									});
								}); */
							}
						});
						das=ss.responseText
					}
					
				}
			});
			
			
			
			function callBackMsg() {
				vm.submit();
				  return das;
				}
		</script>
</body>
</html>
